<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>if (window.top !== window.self) {
        window.top.location = window.location;
    }</script>
</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>
            <h1 class="logo-name">R T</h1>
        </div>
        <h3>任务管理中心(retry task)</h3>

        <form class="m-t" role="form" action="index.html">
            <div class="form-group">
                <input type="text" class="form-control" placeholder="用户名" required="" id="userName">
            </div>
            <div class="form-group">
                <input type="password" class="form-control" placeholder="密码" required="" id="password">
            </div>
            <button type="submit" id="login" class="btn btn-primary block full-width m-b">登 录</button>


            <p class="text-muted text-center">
                <!--<a href="login.html#"><small>忘记密码了？</small></a> |-->
                <a href="register.html">注册一个新账号</a>
            </p>

        </form>
    </div>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>
<script>
    $("#login").click(function () {
        login()
    });

    function login() {
        var password = $("#password").val();
        if (password == "" || password == null || password == undefined) {
            alert("password is null");
            return;
        }
        var userName = $("#userName").val();
        if (userName == "" || userName == null || userName == undefined) {
            alert("userName is null");
            return;
        }
        var loginUrl = "/retrytask/login?userName=" + userName + "&password=" + password;
        $.ajax({
            url: loginUrl,
            type: "GET",
            dataType: "json",
            success: function (result) {
                if (result == null) {
                    return;
                }
                if (result.code == '-999') {
                    return;
                }
                var sucess = result.isSuccess;
                if (sucess == false) {
                    alert(result.errMsg);
                    return;
                } else {
                    window.location.href = "/admin/index.html";
                }

            },
            error: function (err) {
                console.log(err.statusText);
                console.log('异常');
            }/*,
            complete: function (XMLHttpRequest, textStatus) {
                var redirect = XMLHttpRequest.getResponseHeader("Redirect");
                if (redirect == "true") {
                    window.parent.location.href = XMLHttpRequest.getResponseHeader("RedirectUrl");
                }
            }*/
        });
    }

</script>
</body>

</html>
